import type { ClientCacheServiceResult } from "./ClientCache";
import { BaseSearchProp, DataSearchProp, SeniorSearchProp } from "$/elasticsearch-client";

export const ClientSearchService = (cache: ClientCacheServiceResult) => {
  return {
    /**
     * 数据搜索
     */
    async dataSearch(id: string, props: DataSearchProp) {
      const client = await cache.getClientCache(id);
      return await client.dataSearch(props);
    },

    /**
     * 基础搜索
     */
    async baseSearch(id: string, props: BaseSearchProp) {
      const client = await cache.getClientCache(id);
      return await client.baseSearch(props);
    },

    /**
     * 高级搜索
     */
    async seniorSearch(id: string, props: SeniorSearchProp) {
      const client = await cache.getClientCache(id);
      return await client.seniorSearch(props);
    }
  };
};
